package kr.hyunist.androidcomplete01saeildamil.ch13;

import kr.hyunist.androidcomplete01saeildamil.*;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class SeekbarEx extends Activity {
	SeekBar mSeekBar;
	TextView mVolume;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.seekbartest);
		
		mSeekBar= (SeekBar) findViewById(R.id.seekBartest);
		mVolume = (TextView) findViewById(R.id.seekBarvolume);
		
		mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			
			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
				
			}
			
			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
				
			}
			
			@Override
			public void onProgressChanged(SeekBar seekBar, int progress,
					boolean fromUser) {
				
				if(progress < 10){
					progress = 10;
					mSeekBar.setProgress(progress);
				}
				mVolume.setText("화면 밝기 : " + progress);
				WindowManager.LayoutParams params = getWindow().getAttributes();
				params.screenBrightness = (float) progress / 100;
				getWindow().setAttributes(params);
				
			}
			
		});
	}
}
